<template>
  <div class="smart-navigation-demo">
    <div class="demo-header">
      <h1>智能导航系统演示</h1>
      <p>类似图片中展示的导航方式，左侧主菜单 + 右侧子菜单</p>
    </div>

    <div class="demo-content">
      <div class="demo-section">
        <h2>功能特点</h2>
        <div class="features-grid">
          <div class="feature-card">
            <div class="feature-icon">
              <el-icon><Grid /></el-icon>
            </div>
            <h3>左侧主导航</h3>
            <p>清晰的主菜单分类，支持图标和文字显示</p>
          </div>
          
          <div class="feature-card">
            <div class="feature-icon">
              <el-icon><Menu /></el-icon>
            </div>
            <h3>右侧子菜单</h3>
            <p>多列展示子菜单，支持分类和搜索</p>
          </div>
          
          <div class="feature-card">
            <div class="feature-icon">
              <el-icon><Search /></el-icon>
            </div>
            <h3>智能搜索</h3>
            <p>全局搜索功能，快速定位所需功能</p>
          </div>
          
          <div class="feature-card">
            <div class="feature-icon">
              <el-icon><Star /></el-icon>
            </div>
            <h3>收藏功能</h3>
            <p>常用功能收藏，提高操作效率</p>
          </div>
        </div>
      </div>

      <div class="demo-section">
        <h2>使用方法</h2>
        <div class="usage-steps">
          <div class="step">
            <div class="step-number">1</div>
            <div class="step-content">
              <h3>选择导航模式</h3>
              <p>在系统设置中选择"智能导航系统"模式</p>
            </div>
          </div>
          
          <div class="step">
            <div class="step-number">2</div>
            <div class="step-content">
              <h3>点击主菜单</h3>
              <p>点击左侧主菜单项，右侧会显示对应的子菜单</p>
            </div>
          </div>
          
          <div class="step">
            <div class="step-number">3</div>
            <div class="step-content">
              <h3>使用搜索</h3>
              <p>使用顶部搜索框快速查找功能</p>
            </div>
          </div>
          
          <div class="step">
            <div class="step-number">4</div>
            <div class="step-content">
              <h3>收藏常用功能</h3>
              <p>将常用功能添加到收藏夹，快速访问</p>
            </div>
          </div>
        </div>
      </div>

      <div class="demo-section">
        <h2>导航模式切换</h2>
        <div class="mode-switch">
          <el-button 
            type="primary" 
            @click="switchToSmartNavigation"
            :loading="switching"
          >
            <el-icon><Switch /></el-icon>
            切换到智能导航系统
          </el-button>
          
          <p class="switch-tip">
            点击按钮将当前导航模式切换为智能导航系统
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useNavigationStore } from '@/stores/navigation'
import { ElMessage } from 'element-plus'
import { Grid, Menu, Search, Star, Switch } from '@element-plus/icons-vue'

const router = useRouter()
const navigationStore = useNavigationStore()
const switching = ref(false)

const switchToSmartNavigation = async () => {
  switching.value = true
  
  try {
    // 切换到智能导航模式
    navigationStore.setMode('smart-navigation')
    
    // 显示成功消息
    ElMessage.success('已切换到智能导航系统模式')
    
    // 延迟跳转到首页以应用新布局
    setTimeout(() => {
      router.push('/dashboard')
    }, 1000)
    
  } catch (error) {
    ElMessage.error('切换失败，请重试')
    console.error('Navigation mode switch failed:', error)
  } finally {
    switching.value = false
  }
}
</script>

<style scoped>
.smart-navigation-demo {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.demo-header {
  text-align: center;
  margin-bottom: 40px;
}

.demo-header h1 {
  font-size: 32px;
  color: #303133;
  margin-bottom: 12px;
}

.demo-header p {
  font-size: 16px;
  color: #606266;
}

.demo-content {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.demo-section h2 {
  font-size: 24px;
  color: #303133;
  margin-bottom: 20px;
  border-bottom: 2px solid #409eff;
  padding-bottom: 8px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.feature-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  text-align: center;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.feature-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #409eff 0%, #67c23a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: white;
  font-size: 24px;
}

.feature-card h3 {
  font-size: 18px;
  color: #303133;
  margin-bottom: 8px;
}

.feature-card p {
  color: #606266;
  line-height: 1.6;
}

.usage-steps {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.step-number {
  width: 40px;
  height: 40px;
  background: #409eff;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 18px;
  color: #303133;
  margin-bottom: 8px;
}

.step-content p {
  color: #606266;
  line-height: 1.6;
}

.mode-switch {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.switch-tip {
  margin-top: 16px;
  color: #606266;
  font-size: 14px;
}

/* 响应式 */
@media (max-width: 768px) {
  .smart-navigation-demo {
    padding: 16px;
  }
  
  .demo-header h1 {
    font-size: 24px;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .step {
    flex-direction: column;
    text-align: center;
  }
}
</style>
